#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main()
{
    int n;
    char str[100];
    int a = 0, b = 0, c = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%s", &str);
        if (strlen(str) < 8)
        {
            printf("NO\r\n");
            continue;
        }
        if (isdigit(str[0]) != 0)
        {
            printf("NO\r\n");
            continue;
        }
        for (int j = 0; j < n; j++)
        {
            if (islower(str[j]) != 0)
                a++;
            if (isupper(str[j]) != 0)
                b++;
            if (isdigit(str[j]) != 0)
                c++;
        }
        if (a == sizeof(str) || b == sizeof(str) || c == sizeof(str))
        {
            printf("NO\r\n");
            continue;
        }
        printf("YES\r\n");
    }
    return 0;
}